-
Notifications
You must be signed in to change notification settings - Fork 153
zkEVM: add modexp attack #1523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zkEVM: add modexp attack #1523
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments but looks good overall 👍
Thanks @marioevz. I applied the suggestions, and double-checked again the run and has the same expected cycles. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few last comments, thanks!
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Co-authored-by: Mario Vega <marioevz@gmail.com>
Co-authored-by: Mario Vega <marioevz@gmail.com>
Co-authored-by: Mario Vega <marioevz@gmail.com>
Thanks @marioevz for the review, I think it is now ready! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
* add modexp tests Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * leave only 36M gas limit Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * adjustments Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * lints Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * lints and cleanup Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * lints Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * Update tests/zkevm/test_worst_compute.py Co-authored-by: Mario Vega <marioevz@gmail.com> * Update tests/zkevm/test_worst_compute.py Co-authored-by: Mario Vega <marioevz@gmail.com> * Update tests/zkevm/test_worst_compute.py Co-authored-by: Mario Vega <marioevz@gmail.com> * feedback Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> --------- Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> Co-authored-by: Mario Vega <marioevz@gmail.com>
* add modexp tests Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * leave only 36M gas limit Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * adjustments Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * lints Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * lints and cleanup Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * lints Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> * Update tests/zkevm/test_worst_compute.py Co-authored-by: Mario Vega <marioevz@gmail.com> * Update tests/zkevm/test_worst_compute.py Co-authored-by: Mario Vega <marioevz@gmail.com> * Update tests/zkevm/test_worst_compute.py Co-authored-by: Mario Vega <marioevz@gmail.com> * feedback Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> --------- Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> Co-authored-by: Mario Vega <marioevz@gmail.com>
This PR introduces an attack vector for the MODEXP precompile.
We assume 32-byte operands for the base, modulus, and exponent, anticipating the activation of EIP-7883 on mainnet in the near future (TM). Beyond the 32-byte boundary, the cost per unit of work rises, so it is valuable to model that limit from the outset.
The test suite is already parameterised for multiple gas limits (and can easily be extended to cover base/modulo/exp sizes), but for now we target 36M gas-limit since it is the relevant case for zkVMs today.
SP1 cycles: 36M gas limit -> ~27 billion cycles.
cc @kevaundray